<?php

function boolToStr($val) {
    if ($val) {
        return 'tak';
    } else {
        return 'nie';
    }
}

function advPosition($val) {
    switch ($val) {
        case Application_Model_DAO_Adv::PLACE_BOTTOM: return 'Stopka';
        case Application_Model_DAO_Adv::PLACE_TOP: return 'Nagłowek';
        case Application_Model_DAO_Adv::PLACE_RIGHT: return 'Prawa kolumna';
        case Application_Model_DAO_Adv::PLACE_LEFT: return 'Lewa kolumna';
        default: return 'Inna';
    }
}

function advType($val) {
    switch ($val) {
        case Application_Model_DAO_Adv::TYPE_IMG: return 'Grafika';
        case Application_Model_DAO_Adv::TYPE_HTML: return 'Kod HTML';
        default: return 'Inny';
    }
}

echo $this->smartButton('Nowa reklama', $this->url(array('controller' => 'adv', 'action' => 'save',), 'admin', true), array());

echo $this->table($this->list, array(
    'Nazwa' => 'name',
    'Wyświetleń' => 'displayed_cnt',
    'Kliknięć' => 'click_cnt',
    'Typ' => array('eval' => 'advType("${item.type}")'),
    'Pozycja' => array('eval' => 'advPosition("${item.place}")'),
    'Aktywne' => array('eval' => 'boolToStr((bool)"${item.admin_active}")'),
    'Operacje' => array(
//        $this->smartButton('Edycja', $this->url(array('controller' => 'adv', 'action' => 'save', 'id' => '${item.code}'), 'admin', true), array('size' => 'mini',))
        $this->smartButton('Aktywuj', $this->url(array('controller' => 'adv', 'action' => 'activate', 'id' => '${item.code}'), 'admin', true), array('size' => 'mini', 'class' => 'visible-inactive'))
        .
        $this->smartButton('Deaktywuj', $this->url(array('controller' => 'adv', 'action' => 'deactivate', 'id' => '${item.code}'), 'admin', true), array('size' => 'mini', 'class' => 'visible-active'))
    )
        ), array(
    'rowClass' => 'active-${item.admin_active}'
        )
);